#ifndef QUEUE_H_
#define QUEUE_H_

#include <climits>
#include <cstddef>
namespace lxj
{
template<class T, size_t Num = 0>
class Queue {
    static_assert(Num <= 4096, "容量最大为4096");

    T              alloc[Num] = {};
    unsigned short _l, _r, _size;

public:
    Queue() : _l(0), _r(0), _size(0) {}

    T front() const noexcept
    {
        static_assert(Num > 0, "请设置容量大小");
        if (size() < 0) return INT_MIN;
        return alloc[_l];
    }

    size_t size() const { return _size; }

    bool pop()
    {
        static_assert(Num > 0, "请设置容量大小");
        if (size() <= 0) return false;

        _l == Num - 1 ? _l = 0 : _l++;
        _size--;
        return true;
    }

    bool push(const T& value)
    {
        static_assert(Num > 0, "请设置容量大小");
        if (size() >= Num) return false;
        if (_r == Num) {
            _r          = 0;
            alloc[_r++] = value;
            _size++;
        }
        else {
            alloc[_r++] = value;
            _size++;
        }
        return true;
    }
};
}   // namespace lxj

#endif